<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title>thymeleaf模板测试</title>
    <script type="text/javascript" th:src="@{js/jquery-1.9.1.min.js}"></script>
</head>
<body>
<div>
    <span th:text="${singlePerson.name}"></span>
    <div th:if="${not #lists.isEmpty(people)}">
        <div>
            <h3>列表</h3>
        </div>
        <div>
            <ul>
                <li th:each="person:${people}">
                    <span th:text="${person.name}"></span>
                    <span th:text="${person.age}"></span>
                    <button th:onclick="'getName(\''+${person.name} + '\');'">获得名字</button>
                </li>
            </ul>
        </div>
    </div>
</div>

<script th:inline="javascript">
    var single = [[${singlePerson}]];
    console.log(single.name + "/" + single.age);

    function getName(name){
        console.log(name);
    }
</script>
</body>
</html>